<?php

class CarregaLogin{
	
	var $db;
	
	function CarregaLogin(){
		@session_start();	
		$this->db = new Persist;
	}
	
	function loga($login,$pwd){
		$this->db->sql = " SELECT * FROM cadastro
							 WHERE login = '$login' AND senha = '$pwd' ";
		
		if($this->db->ler() > 0){
			$this->db->ini();
			
			$_SESSION["USR_I"] = $this->db->id;
			$_SESSION["USR_L"] = $login;
			$_SESSION["USR_S"] = $pwd;
			$_SESSION["USR_JOIN"] = "1";
		}
		
	}
	
	function pegaCampo($campo){
		return $_SESSION[$campo];
	}
	
	function logado(){
		if(@$_SESSION["USR_JOIN"] == "1")
			return 1;
		return 0;
	}
	
	function deslogar(){
		unset($_SESSION["USR_I"]);
		unset($_SESSION["USR_L"]);
		unset($_SESSION["USR_S"]);
		unset($_SESSION["USR_JOIN"]);
	}
}
?>